---
title: PageRange
summary: API reference for PageRange.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-17
library: PdfAPI.Core
reference_type: package
---

# PageRange

`PageRange` is the immutable implementation of `IPageRange`, and its static `Parse` method converts a comma-separated page-expression string (e.g., `"1-5,7,9-*,*"`) into an array of ranges — the mechanism behind [Parse a page expression](../../operations/op-11-parse-a-page-expression.md). It carries a `[JsonConstructor]` companion constructor so it can round-trip through serialization.

## Purpose
- Represents one contiguous or single-page selection with computed classification flags (`IsPartial`, `IsOriginal`, `IsSingle`).
- Parses a page-expression string into an array of `PageRange` values, silently skipping tokens that do not match the grammar. ([BR-25](../../business-rules.md#br-25-page-expression-token-grammar), [BR-26](../../business-rules.md#br-26-unmatched-tokens-are-skipped-silently))
- Renders a range back to its expression form via `ToString()`.

## Context
- Namespace: `PdfAPI.Core`
- Assembly/package: `PdfAPI.Core`

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| PageRange(int, int) | `PageRange(int start, int stop)` | Constructs an explicit start/stop range. |
| PageRange(int, bool) | `PageRange(int start, bool isSinglePage = true)` | Constructs a single-page range, or an open-ended range starting at `start` when `isSinglePage` is false. |
| PageRange() | `PageRange()` | Parameterless constructor used for JSON deserialization. |
| StartPage | `int StartPage { get; }` | The first page (1-based) included in the selection. |
| StopPage | `int StopPage { get; }` | The last page included in the selection; `-1` denotes open-ended. ([BR-15](../../business-rules.md#br-15-open-ended-stop-page-means-through-last-page)) |
| IsPartial | `bool IsPartial { get; }` | Indicates the selection covers a subset of pages. |
| IsOriginal | `bool IsOriginal { get; }` | Indicates the selection spans the entire original document. ([BR-14](../../business-rules.md#br-14-original-range-copies-the-whole-document)) |
| IsSingle | `bool IsSingle { get; }` | Indicates the selection covers exactly one page. |
| Parse(string) | `static PageRange[] Parse(string text)` | Splits a comma-separated expression into tokens and converts each recognised token into a `PageRange`, skipping tokens that do not match. ([BR-25](../../business-rules.md#br-25-page-expression-token-grammar), [BR-26](../../business-rules.md#br-26-unmatched-tokens-are-skipped-silently), [BR-27](../../business-rules.md#br-27-absent-or-non-positive-stop-page-is-open-ended), [BR-28](../../business-rules.md#br-28-asterisk-means-all-pages), [BR-29](../../business-rules.md#br-29-bare-page-number-is-a-single-page-range)) |
| ToString() | `override string ToString()` | Renders the range back into its page-expression textual form. |

## Behavioral notes
- A stop page of zero or less in a `start-stop` token is normalised to `-1` (open-ended) during parsing. ([BR-27](../../business-rules.md#br-27-absent-or-non-positive-stop-page-is-open-ended))
- A bare `*` token produces an all-pages range (`1` to `-1`). ([BR-28](../../business-rules.md#br-28-asterisk-means-all-pages))

## Constraints and usage notes
- `Parse` never throws on malformed input; it simply omits unmatched tokens from the result, which can silently yield an empty array. ([BR-26](../../business-rules.md#br-26-unmatched-tokens-are-skipped-silently))

## Related documentation
- [Index](../../index.md)
- [Overview](../../overview.md)
- [Architecture](../../architecture.md)
- [Dependencies](../../dependencies.md)
- [Operations and processes](../../operations-processes.md)
- [Business rules](../../business-rules.md)
- [Security and authorization](../../security-authorization.md)
- [API reference](../index.md)

## Sources
- `PdfAPI.Core\Extract\PageRange.cs`
